// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "RtMidi.h"
#include "GameFramework/Pawn.h"
#include "Components/BoxComponent.h"
#include "MidiPawn.generated.h"

UCLASS()
class CLASS14_API AMidiPawn : public APawn
{
	GENERATED_BODY()

public:
	AMidiPawn();
	
	UPROPERTY(VisibleAnywhere)
	UBoxComponent* _box;
	
protected:
	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type reason) override;

	static void MidiCallback(double deltaT, std::vector<unsigned char>* msg, void* userData);
	void ControlMotion(unsigned char num, unsigned char value);
	void NoteMotion(unsigned char num, unsigned char value, bool on);
	bool SelectDevice();

	RtMidiIn* _midiIn;
	int _xStart, _yStart;
	float _xDiff, _yDiff, _zDiff;

public:	
	virtual void Tick(float DeltaTime) override;
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
	void OnMouseMove(FVector v);
};
